<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>请使用微信扫描安装</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    <link rel="Shortcut Icon" href="cachet.ico">
    <script src="/asset/js/jquery.min.js"></script>
    <script src="/asset/js/jquery.qrcode.min.js"></script>
</head>
<body >
<div class="alert_bigbox">
    <div id="codeico" class="ewm_codeico"></div>
    <p class="text-center">请使用微信扫描二维码安装</p>
</div>

<div class="x-body">
	<div style="text-align:right;">
	<a href="javascript:void(0);" id="appltest" class="layui-btn layui-btn-sm">申请测试</a>
    </div>
	<table class="layui-table  layui-form" mytable" lay-even="" lay-skin="nob">
            <thead>
            <tr>
                <th>申请时间</th>
                <th>可用次数</th>
                 <th>已用次数</th>
                <th>失效时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            		<#list acts as item>
                <tr>
                    <td>${item.applyTime?string('yyyy-MM-dd')}</td>
                    <td>${item.totalTimes}</td>
                    <td>${item.useTimes}</td>
                    <td>
                    		<#if item.invalidTime??>
                    		${item.invalidTime?string('yyyy-MM-dd')}
                    		<#else>
                    		永久
                    		</#if>
                    </td>
                    <td>
                  	<a href="javascript:used(${item.sealId},${item.devicesActId},${item.devicesId},'TEST');">测试</a>
                    	</td>
                </tr>
                </#list>
            </tbody>
        </table>

</div>


<script src="/asset/layui/layui.js"></script>
<script>

	function used(sealId,devicesActId,devicesId,usedType){
	
			var field = {
        			devicesActId:devicesActId,
        			devicesId:devicesId,
        			sealId:sealId,
        			usedType:'TEST'
        		}
        		
        		$.ajax({
	      			type:"POST", 
	      			url:"/devices/used.htm",
	      			data:field,
	      			success:function(result) {
			      
			      		if(result.code=='1'){
			      			layer.msg("使用成功");
			      			location.reload();
			      		}else{
			      		 	layer.msg(result.msg);
			      		}
			      
			    	} 
			    }); 
	}


    layui.use(['element','form'], function(){
        var element = layui.element;
        var layer = layui.layer;
        var form = layui.form;

        
        
        $("#appltest").click(function(){
        
        		var field = {
        			applyTimes:3,
        			applyType:'TEST_APPLY',
        			devicesId:'${devices.devicesId}',
        			sealId:'${devices.sealId}',
        			cause:'印章测试申请'
        		}
        		
        		$.ajax({
	      			type:"POST", 
	      			url:"/apply/submit.htm",
	      			data:field,
	      			success:function(result) {
			      
			      		if(result.code=='1'){
			      			layer.msg("申请成功");
			      			location.reload();
			      		}else{
			      		 	layer.msg(result.msg);
			      		}
			      
			    	 } 
			    }); 
        })

    });
</script>
</body>
</html>